#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" This module defines the URL namespace for tack_apitest.


"""
from tack.lib.urlns import *
from tack.lib.pdftools import pdfreport

def poster(env, resp):
    resp(status_codes.okay, content_headers.default_plain())
    values = env['form']
    return ['posted: ' ] + [str(values)]


def deleter(env, resp):
    resp(status_codes.okay, content_headers.default_plain())
    return ['deleted']


def putter(env, resp):
    resp(status_codes.created, content_headers.default_plain())
    return ['putted value: '] + [ str(env['form']) ]


urls = [
    ('/api/test/echo/.*',      'GET',    echo_app()),
    ('/api/test/echo/',      'GET|POST',    echo_app()),
    ('/api/test/string/',    'GET',    string_app('string test')),
    ('/api/test/poster/',    'POST',   formreader(poster)),
    ('/api/test/deleter/\d+/','DELETE', deleter),
    ('/api/test/putter/',    'PUT',    formreader(putter)),
    ('/api/test/pdf/',       'POST',   formreader(pdfreport(None)))
]
